module BooksHelper
  def books_cant_borrow
    brs = BorrowRec.find(:all, :conditions => "status = 'confirmed' or status = 'requested' or status = 'delivered' or status = 'reserved' or status = 'waiting'")
    books = []
    if brs.count > 0
      brs.each {|b| books.push Book.find(b.book_id)}
    end
    books
  end

  def books_cant_reserve
    brs = BorrowRec.find(:all, :conditions => "status = 'reserved' or status = 'waiting' or ((status = 'requested' or status = 'confirmed' or status = 'delivered') and user_id = #{session[:user_id]})")
    books = []
    if brs.count > 0
      brs.each {|b| books.push Book.find(b.book_id)}
    end
    books
  end

  def borrowed_books
    brs = BorrowRec.find(:all, :conditions => "user_id = #{session[:user_id]} and status = 'confirmed'")
    books = []
    if brs.count > 0
      brs.each {|b| books.push Book.find(b.book_id)}
    end
    books
  end

end
